package com.boss.common.enums;

/**
 * <br>Title: 工作流操作类型枚举类 
 * <br>Description: 工作流操作类型枚举类 ，在走工作流使用
 * <br>Author:朱孝恒(zhuxiaoheng@bosssoft.com.cn)
 * <br>Date:2019-6-21
 */
public enum ActionTypeEnum {


  /**
   * 录入
   */
  WF_INPUT {
    @Override
    public String getActionTypeCode() {
      return "1";
    }

    @Override
    public String getActionTypeName() {
      return "录入(流程启动)";
    }
  },
  /**
   * 送审
   */
  WF_AUDIT {
    @Override
    public String getActionTypeCode() {
      return "2";
    }

    @Override
    public String getActionTypeName() {
      return "审核（完成当前任务）";
    }
  },
  /**
   * 撤销
   */
  WF_RECALL {
    @Override
    public String getActionTypeCode() {
      return "3";
    }

    @Override
    public String getActionTypeName() {
      return "撤销";
    }
  },
  /**
   * 修改
   */
  WF_EDIT {
    @Override
    public String getActionTypeCode() {
      return "4";
    }

    @Override
    public String getActionTypeName() {
      return "修改";
    }
  },
  /**
   * 删除
   */
  WF_DEL {
    @Override
    public String getActionTypeCode() {
      return "5";
    }

    @Override
    public String getActionTypeName() {
      return "删除";
    }
  },
  /**
   * 退回
   */
  WF_BACK {
    @Override
    public String getActionTypeCode() {
      return "6";
    }

    @Override
    public String getActionTypeName() {
      return "退回";
    }
  },
  /**
   * 作废
   */
  WF_BE_FREEDOM_NODE {
    @Override
    public String getActionTypeCode() {
      return "7";
    }

    @Override
    public String getActionTypeName() {
      return "作废";
    }
  },
  /**
   * 退回到录入
   */
  WF_BACK_START {
    @Override
    public String getActionTypeCode() {
      return "8";
    }

    @Override
    public String getActionTypeName() {
      return "退回到录入";
    }
  },
  /**
   * 退回到指定节点
   */
  WF_BACK_NODE {
    @Override
    public String getActionTypeCode() {
      return "9";
    }

    @Override
    public String getActionTypeName() {
      return "退回到指定节点";
    }
  },
  /**
   * 录入并送审
   */
  WF_INPUT_AUDIT {
    @Override
    public String getActionTypeCode() {
      return "12";
    }

    @Override
    public String getActionTypeName() {
      return "录入(流程启动),并送审";
    }
  },
  /**
   * 撤销退回
   */
  WF_RECALL_RETURN {
    @Override
    public String getActionTypeCode() {
      return "31";
    }

    @Override
    public String getActionTypeName() {
      return "撤销退回";
    }
  };
  /**
   * 获取操作类型code
   * <br>Description:获取操作类型code
   * <br>Author:朱孝恒(zhuxiaoheng@bosssoft.com.cn)
   * <br>Date:2019-6-21
   * @return String 操作类型code
   */
  public abstract String getActionTypeCode();

  /**
   * 获取操作类型名称
   * <br>Description:获取操作类型名称
   * <br>Author:朱孝恒(zhuxiaoheng@bosssoft.com.cn)
   * <br>Date:2019-6-21
   * @return String 操作类型name
   */
  public abstract String getActionTypeName();

  /**
   * 将code转换为枚举类
   * <br>Description:将code转换为枚举类，如果code不匹配则返回nul
   * <br>Author:朱孝恒(zhuxiaoheng@bosssoft.com.cn)
   * <br>Date:2019-6-21
   * @param code 操作类型CODE
   * @return 操作类型枚举类
   */
  public static ActionTypeEnum toEnum(String code) {
    if (ActionTypeEnum.WF_INPUT.getActionTypeCode().equals(code)) {
      return ActionTypeEnum.WF_INPUT;
    } else if (ActionTypeEnum.WF_AUDIT.getActionTypeCode().equals(code)) {
      return ActionTypeEnum.WF_AUDIT;
    } else if (ActionTypeEnum.WF_RECALL.getActionTypeCode().equals(code)) {
      return ActionTypeEnum.WF_RECALL;
    } else if (ActionTypeEnum.WF_EDIT.getActionTypeCode().equals(code)) {
      return ActionTypeEnum.WF_EDIT;
    } else if (ActionTypeEnum.WF_DEL.getActionTypeCode().equals(code)) {
      return ActionTypeEnum.WF_DEL;
    } else if (ActionTypeEnum.WF_BACK.getActionTypeCode().equals(code)) {
      return ActionTypeEnum.WF_BACK;
    } else if (ActionTypeEnum.WF_BACK_START.getActionTypeCode().equals(code)) {
      return ActionTypeEnum.WF_BACK_START;
    } else if (ActionTypeEnum.WF_BACK_NODE.getActionTypeCode().equals(code)) {
      return ActionTypeEnum.WF_BACK_NODE;
    } else if (ActionTypeEnum.WF_INPUT_AUDIT.getActionTypeCode().equals(code)) {
      return ActionTypeEnum.WF_INPUT_AUDIT;
    } else if (ActionTypeEnum.WF_BE_FREEDOM_NODE.getActionTypeCode().equals(code)) {
      return ActionTypeEnum.WF_BE_FREEDOM_NODE;
    } else if (ActionTypeEnum.WF_RECALL_RETURN.getActionTypeCode().equals(code)) {
      return ActionTypeEnum.WF_RECALL_RETURN;
    } else {
      return null;
    }
  }
}
